package com.diyunapp.xilinapp.me;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.diyunapp.xilinapp.R;
import com.diyunapp.xilinapp.login.LoginActivity;
import com.diyunapp.xilinapp.main.MainActivity;
import com.diyunapp.xilinapp.selfdefine.StatusBarFragmentActivity;
import com.diyunapp.xilinapp.utils.FormatConfirm;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class SettingsActivity extends StatusBarFragmentActivity {

    @Bind(R.id.go_back)
    ImageView goBack;
    @Bind(R.id.about_us)
    LinearLayout aboutUs;
    @Bind(R.id.ask_phone)
    LinearLayout askPhone;
    @Bind(R.id.web_notice)
    LinearLayout webNotice;
    @Bind(R.id.check_update)
    LinearLayout checkUpdate;
    @Bind(R.id.sure_to_quit)
    TextView sureToQuit;
    @Bind(R.id.lin_wenjuan)
    LinearLayout linWenjuan;
    @Bind(R.id.lin_kefu)
    LinearLayout linKefu;
    private String kefuQQ1="3426358341";
    private String kefuQQ2="3438315989";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_settings);
        ButterKnife.bind(this);
        View headView;
        headView = findViewById(R.id.setting_menubar_inc);
        super.MenuWidget(headView);
    }

    @OnClick({R.id.go_back, R.id.about_us, R.id.web_notice, R.id.check_update, R.id.sure_to_quit, R.id.lin_wenjuan,R.id.lin_kefu})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.go_back:
                finish();
                break;
            case R.id.about_us:
                nextAct(AboutUsActivity.class);
                break;
            case R.id.web_notice:
                nextAct(WebNoticeActivity.class);
                break;
            case R.id.check_update:
                nextAct(VersionsUpdateActivity.class);
                break;
            case R.id.lin_wenjuan:
//                nextAct(SurveyActivity.class);
                if (MainActivity.myLogin.isLoginState()) //用户已登录，进入设置页面
                {
                    Intent setInt1 = new Intent(this, SurveyActivity.class);
                    startActivity(setInt1);
                } else {
                    Intent logInt = new Intent(this, LoginActivity.class);
                    startActivity(logInt);
                }
                break;
            case R.id.lin_kefu:
               int num= (int)(1+Math.random()*(2-1+1));
                if (num==1){
                    FormatConfirm.startQQ(this,kefuQQ1);
                }else{
                    FormatConfirm.startQQ(this,kefuQQ2);
                }
                break;
            case R.id.sure_to_quit:
                setResult(1);
                finish();
                break;
        }
    }

    public void nextAct(Class act) {
        Intent intent = new Intent();
        intent.setClass(this, act);
        startActivity(intent);
    }
}
